package mr.zhang.controller;

import mr.zhang.dao.domain.MerchantProperty;
import mr.zhang.service.MerChantPropertyService;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class SaveMerchantPropertyController extends AbstractController {
	
	private MerChantPropertyService merChantPropertyService;
	
	public MerChantPropertyService getMerChantPropertyService() {
		return merChantPropertyService;
	}



	public void setMerChantPropertyService(
			MerChantPropertyService merChantPropertyService) {
		this.merChantPropertyService = merChantPropertyService;
	}



	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		
		
		String property_name = (String)request.getParameter("property_name");
		
		int merchant_id =  Integer.parseInt(request.getParameter("merchant_id"));
		
		
		MerchantProperty merchantProperty = new MerchantProperty();
		
		merchantProperty.setProperty_name(property_name);
		
		merchantProperty.setMerchant_id(merchant_id);
		
		this.merChantPropertyService.saveMerchantProperty(merchantProperty);
		
		return new ModelAndView("redirect:/queryMerchantproperty.do");
	}

}
